<?php

class MemberCsv{
	
	//原生数据
	private $data = array();
	//每一行
	private $lines = array();
	
	private $data_list = array();
	
	//每一行
	private $line_count = 0;
	
	function __construct(){
		
	}
	
	//数组转
	function array_to_data($array){
		
		$this->data = $array;
		$this->line_count = count($this->data);

		$keys = array(
			'plantform_id',
			'member_name' ,
			'member_pwd' ,
			'member_pay_pwd' ,
			'mobile_phone' ,
			'email' ,
			'email_pwd',
			'is_internal'
		);
		
		
		foreach($this->data as $i => $d){
			//合并
			$line = array_combine($keys, $d);
			
			$is_internal = 0;
			if($line['is_internal'] == '是'){
				$is_internal = 1;	
			}
			
			$line['is_internal'] = $is_internal;
			
			$this->lines[] = $line;
		}
		
		return $this->lines;
	}

	
	//数组转
	function update_array_to_data($array){
		
		$this->data = $array;
		$this->line_count = count($this->data);

		$keys = array(
			'member_id',
			'member_name' ,
			'member_pwd' ,
			'member_pay_pwd' ,
			'mobile_phone' ,
			'email' ,
			'email_pwd',		
			'disabled',
			'is_internal',
			'last_use_time'
		);
		
		
		foreach($this->data as $i => $d){
			//合并
			$line = array_combine($keys, $d);
			
			$is_internal = 0;
			if($line['is_internal'] == '是'){
				$is_internal = 1;	
			}
									
			$line['is_internal'] = $is_internal;
			
			$disabled = '启用';
			if($line['disabled']){
				$disabled = '禁用';	
			}
									
			$line['disabled'] = $disabled;
			
			
			
			$this->lines[] = $line;
		}
		
		return $this->lines;
	}
	
	
}

?>